package com.ssy.lingxi.purchase.api.enums.purchase;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 采购能力-采购询价单  外部操作记录状态枚举
 *
 * @author lxc
 * @date 2022/2/25
 */
public enum PurchaseInquiryExternalOperationRecordEnum {

    INITIATE_QUOTATION(1, "发起下轮报价"),
    SUBMIT_PURCHASE_ORDER(2, "提交采购需求单"),
    SUBMIT_QUOTATION(3, "提交报价单"),
    TO_VOID(4, "作废");
    private Integer state;
    private String name;

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    /**
     * 针对数据库储存Integer类型字段
     * @return
     */
    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.state);
    }

    /**
     * 针对数据库储存String类型字段
     * @return
     */
    public String getCHName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    PurchaseInquiryExternalOperationRecordEnum(Integer state, String name) {
        this.state = state;
        this.name = name;
    }

    public static String getName(String name){
        PurchaseInquiryExternalOperationRecordEnum workEnum = Arrays.stream(PurchaseInquiryExternalOperationRecordEnum.values()).filter(v -> v.getCHName().equals(name)).findAny().orElse(null);
        return null == workEnum ? "" : LanguageHolder.getName(PurchaseInquiryExternalOperationRecordEnum.class, workEnum.getState());
    }
}
